package educationaladministrationsystem.CSM.Mapper.Service.StudentAndTeacher.Student;

import educationaladministrationsystem.CSM.Mapper.Service.ServiceInterface.StudentAndTeacherInterface.Student.StudentElectiveCourse;
import educationaladministrationsystem.Class.Course;
import educationaladministrationsystem.CSM.Mapper.StudentAndTeacher.Student.StudentElectiveCourseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class StudentElectiveCourseService implements StudentElectiveCourse {
    @Autowired
    private StudentElectiveCourseMapper studentElectiveCourseMapper;

    @Override
    public List<Course> getAllCourse(int page, int pageNumber) {
        return studentElectiveCourseMapper.getAllCourse((page - 1) * pageNumber, pageNumber);
    }

    @Override
    public int getAllCoursePage(int pageNumber) {
        return (int) Math.ceil((double) studentElectiveCourseMapper.getAllCourseCount() / pageNumber);
    }

    @Override
    public void addNewCourse(String UID, String classId) {
        studentElectiveCourseMapper.addNewCourse(UID, classId);
    }

    @Override
    public Map<Integer, Integer> peopleNumAndSum(String classId) {
        return studentElectiveCourseMapper.peopleNumAndSum(classId);
    }

    @Override
    public void updateCoursePeopleNumber(int num, String id) {
        studentElectiveCourseMapper.updateCoursePeopleNumber(num, id);
    }

    @Override
    public void deleteCourse(String UID, String classId) {
        studentElectiveCourseMapper.deleteCourse(UID, classId);
    }

    @Override
    public List<String> getHaveSelectCourse(String id) {
        return studentElectiveCourseMapper.getHaveSelectCourse(id);
    }

    @Override
    public int getDegree(String id) {
        return studentElectiveCourseMapper.getDegree(id);
    }

    @Override
    public String getCourseDegreeDemand(String id) {
        return studentElectiveCourseMapper.getCourseDegreeDemand(id);
    }
}
